package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo4
{
    public static void main(String[] args) throws Exception
    {
        Scanner scanner = new Scanner(System.in);
        System.out.println("className  = ");
        String className = scanner.nextLine();
        System.out.println("methodName = ");
        String methodName = scanner.nextLine();
        Class cls = Class.forName(className);
        Object o1 = cls.newInstance();
        Method sayHello = cls.getMethod(methodName);
        Method say = cls.getMethod(methodName, String.class);
        Method say1 = cls.getMethod("say", String.class, int.class);
        say.invoke(o1,"hahahaha");
        sayHello.invoke(o1);
        say1.invoke(o1,"WDNMD",3);
    }
}
